package com.fast.util;

import org.junit.After;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.transaction.annotation.Transactional;

/**
 * 基础测试类 <br>
 * Transaction 设置为true不会改变数据库数据，设置为false会改变数据
 * 
 * @author Tonny Luo
 *
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath*:/test-context-persistence.xml" })
@Transactional
@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true)
public class SpringTestBase {
	protected final Logger logger = LoggerFactory.getLogger(getClass());

	/*
	 * 一些公用的“初始化”代码
	 */
	@Before
	public void before() {
		logger.info("[---------------------Test Start---------------------]");
	}

	/**
	 * 一些公用的“销毁”代码
	 */
	@After
	public void after() {
		logger.info("[---------------------Test Ended---------------------]");
	}
}
